package Test6.Operation;

import Test6.BOOK.Book;
import Test6.BOOK.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOperatopn{
    public void work(BookList bookList){
        System.out.println("请输入要借出的书:");
        Scanner sc = new Scanner(System.in);
        String finding= sc.nextLine();
        int flag = 0;
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            if(finding.compareTo(bookList.getBooks(i).getName())==0){
                if(bookList.getBooks(i).isIsBorrowed()==false)
                {
                    bookList.getBooks(i).setIsBorrowed(true);
                }else {
                    System.out.println("该书已经被借出!");
                }
                flag = 1;
            }
        }
        if(flag==0){
                System.out.println("没有找到该书,即将退出程序!");
                System.exit(0);
        }
        new OutSystem().outSystem();

    }
}
